package test;

import Book.Book;
import Book.BookList;
import Operation.*;

import java.util.Scanner;
public class test {
    public static void main(String[] args){
        System.out.println("1:添加图书信息");
        System.out.println("2:删除图书信息");
        System.out.println("3:查找图书信息");
        System.out.println("0:退出系统");
        
        Scanner scan = new Scanner(System.in);

        BookList bookList = new BookList();
 
        IOperation iOperation = null;
        do {
            System.out.print("欢迎来到图书管理后台，请输入序号选择操作:");
            int input = scan.nextInt();
            if(input == 0){
                System.out.println("退出成功");
                return;
            }
            switch(input){
            	case 1:
            		iOperation = new Add();
            		break;
            	case 2:
            		iOperation = new Delete();
            		break;
            	case 3:
            		iOperation = new Find();
            		break;
            	default:
            		System.out.println("输入错误，请重新输入！");
            }
            try {
                iOperation.work(bookList);
            }catch(OperationException e){
                System.out.println(e.getMessage());
            } catch (Exception e) {
                e.printStackTrace();
            }

        }while(true);
    }
}
